/*******************************************************************
 * 外语翻译平台(translate) 
 *
 * 成都一亿信息技术公司 版权所有
 *
 * Copyright (C) 2010 Transer Information Technology Co., Ltd.
 *
 * @Version : 1.0 2010-12-29 上午11:08:05
 *
 * RegisteAction.java 
 *
 *
 *******************************************************************/
package com.transer.web.action.signup;

import com.transer.persistance.bean.User;
import com.transer.persistance.dao.IUserDao;
import com.transer.web.action.AuthCodeActionSupport;

/**
 * 
 * class defination are there
 * 
 * @author mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
public class RegisteAction extends AuthCodeActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5515990599207197249L;
	// 用户操作
	protected IUserDao userDao;
	// 用户
	protected User user;
	// 确认密码
	protected String confirmPwd;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		// 如果两次输入的密码不一致,提示
		if (!confirmPwd.equals(user.getPassword())) {
			addFieldError("confirmPwd", getText("error.password.not.equal"));
		}
		// EMAIL是否存在
		boolean exsit = userDao.isEmailExsit(user.getEmail()) != null;
		// 存在
		if (exsit) {
			addFieldError("user.email", getText("error.email.exsit"));
		}
		// 昵称是否存在
		exsit = userDao.isNikeNameExsit(user.getNikeName());
		if (exsit) {
			addFieldError("user.nikeName", getText("error.nikename.exsit"));
		}
		return null;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getConfirmPwd() {
		return confirmPwd;
	}

	public void setConfirmPwd(String confirmPwd) {
		this.confirmPwd = confirmPwd;
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}
}